﻿var $url = '';

var data = {
    apiUrl: utils.getQueryString('apiUrl'),
    siteId: utils.getQueryString('siteId'),
    pageLoad: false,
    accountCount: 0,
    enrollmentCount: 0,
    courseCount: 0,
    activityCount: 0
};

var methods = {

    loadPage: function () {
        var $this = this;
        var urlGetAccountCount = '/account/count';
        var urlGetEnrollmentCount = '/enrollment/count';
        var urlGetContentCount = '/content/count';

        $api.get(urlGetAccountCount).then(function (response) {
            $this.pageLoad = true;
            $this.accountCount = response.data.count;
        });

        $api.get(urlGetEnrollmentCount, {
            params: {
                category: 'all'
            }
        }).then(function (response) {
            $this.pageLoad = true;
            $this.enrollmentCount = response.data.count;
        });

        $api.get(urlGetContentCount, {
            params: {
                siteId: $this.siteId,
                cname: 'course'
            }
        }).then(function (response) {
            $this.pageLoad = true;
            $this.courseCount = response.data.count;
        });

        $api.get(urlGetContentCount, {
            params: {
                siteId: $this.siteId,
                cname: 'activity'
            }
        }).then(function (response) {
            $this.pageLoad = true;
            $this.activityCount = response.data.count;
        });
    },
};

var $vue = new Vue({
    el: '#main',
    data: data,
    methods: methods,
    computed: {},
    created: function () {
        this.loadPage();
    }
});